﻿using Merlba.Plinq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;

namespace Merbla.Plinq.Tests
{
    
    
    /// <summary>
    ///This is a test class for PersonFilterTest and is intended
    ///to contain all PersonFilterTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PersonFilterTest
    {

        private static IList<Person> GetPeople()
        {
            return Builder<Person>
               .CreateListOfSize(1000000)
               .WhereTheFirst(500000).Have(x => x.BirthDate = DateTime.Now.AddDays(10))
               .AndTheNext(500000).Have(x => x.BirthDate = DateTime.Now.AddDays(-10))
                   .Build();
        }
     
 
        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
 _people = GetPeople();

        }
     
        static IList<Person> _people;
        [TestInitialize()]
        public void MyTestInitialize()
        {

           
        } 

        [TestMethod()]
        public void FilterData()
        { }

        [TestMethod()]
        public void FilterPeople()
        {
            //Arrange
            PersonFilter target = new PersonFilter();   

            //Act
            IQueryable<Person> actual = target.FilterPeople(_people);

            //Assert
            Assert.AreEqual(500000, actual.Count());

        }

        [TestMethod()]
        public void FilterPeopleAsParallel()
        {
            //Arrange
            PersonFilter target = new PersonFilter();

            //Act
            IQueryable<Person> actual = target.FilterPeopleAsParallel(_people);

            //Assert
            Assert.AreEqual(500000, actual.Count());
        }
    }
}
